<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<%@include file="/common/repairAddress.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>养护工程项目--${fns:getConfig('productName')}</title>
<%@include file="/common/uihead.jsp" %>
<%@include file="/common/upload.jsp" %>
<script src="${ctxStatic}/js/public/public.js" type="text/javascript"></script>
<style type="text/css">
textarea{
height:55px !important;
}
</style>
</head>
<body>
	<ul class="nav nav-tabs" style="margin:0 4px 4px 4px;">
		<c:forEach items="${list}" var="menu"  varStatus="idxStatus">
			<li class="${menu.tag eq tag?'active':''}">
				<a href="${ctx}/${menu.href}${fn:indexOf(menuChild.href, '?') eq -1?'?':'&'}left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}&filter_EQS_tag=${menu.tag}">
					<i class="icon icon-list" style="margin-right:10px"></i><span>${menu.name}</span>
				</a>
			</li>
		</c:forEach>
	</ul>
    <tags:message content="${msg}" />
<form id="mainForm" class="form-horizontal" role="form" method="get"  name="mainForm">
<div class="breadcrumb form-search" style="background-color: #f5f5f5;">
			<div>
				<label>关键字:</label>
				<input type="text" oninput="queryForGrid('mainForm','jqGrid')" onporpertychange="queryForGrid('mainForm','jqGrid')" name="filter_LIKES_projectName_OR_projectNumber_OR_year" value="${filter_LIKES_projectName_OR_projectNumber_OR_year}" placeholder="养护项目工程查询" />
				<sec:authorize ifAnyGranted="ROLE_jsbz_xxjc_yhgcfa_editor">
				<a href="#javascript:void(0)" onclick= "openPublicModal();"  class="btn btn-primary" role="button" >新增&nbsp;</a>
				</sec:authorize>
			</div>
		</div>
  <table id="jqGrid"></table>
  <div id="jqGridPager"></div> 
</form>
<form id="publicForm" name="publicForm">
   <input type="hidden" name="token" value="${token}" id="token">
   <input type="hidden" name="id" id="id" value="">
   <input type="hidden" name="tag" id="tag" value="${tag}">
<div class="modal fade" id="publicModal" tabindex="-1" role="dialog" aria-labelledby="publicModal" aria-hidden="true" data-backdrop="static" style="width:920px;max-height:700px">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel">新增/修改</h4>
					</div>
					<div class="modal-body" >
						<table class="table"  style="border: none;margin-bottom: -14px">
							<tbody>
								<tr>
									<td style="width:120px;"> 项目年度<font color="red">&nbsp;*</font>：</td>
									<td style="width:340px;">
										<input  id="year" name="year" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy', maxDate:'%y'})" class="Wdate required" type="text"/>
									</td>
									<td style="width:100px;">项目编号<font color="red">&nbsp;*</font>：</td>
									<td style="width:340px;">
										<input name="projectNumber" id="projectNumber" maxlength="50" type='text' value="" class="required">
									</td>
								</tr>
								<tr>
									<td>项目名称<font color="red">&nbsp;*</font>：</td>
									<td>
										<input name="projectName" id="projectName" maxlength="125" type='text' value="" class="required">
									</td>
									<td> 项目类型<font color="red">&nbsp;*</font>：</td>
									<td>
										<pt:code name="projectType" category="2503" hasEmpty="false" default=""></pt:code>
									</td>
								</tr>
								<tr>
									<td >病害诊断分析：</td>
									<td>
										<pt:code name="diagnoses" category="2501" hasEmpty="false" default=""></pt:code>
									</td>
									<td >养护计划：</td>
									<td>
										<pt:code name="maintenancePlan" category="2502" hasEmpty="false" default=""></pt:code>
									</td>
								</tr>
								<tr>
									<td>养护效果：</td>
									<td>
										<pt:code name="maintenanceEffect" category="2500" hasEmpty="false" default=""></pt:code>
									</td>
								</tr>
								<tr>
									<td>备注：</td>
									<td colspan="3">
										<div class="wordCount wyInline" id="wordCount">
											<textarea placeholder="文件内容描述" rows='3' id="remark"
												name="remark"></textarea>
											<span class="wordwrap"><var class="word">200</var>/200</span>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="modal-footer" style="padding:4px 15px 5px;">
						<button type="button" class="btn btn-default" data-dismiss="close">关闭</button>
						<button type="button" class="btn btn-danger" onclick='publicDel("${ctx}/mainTenanceProject/delete.do");' style="display:none;" id="delPublic">删除</button>
						<button type="submit" class="btn btn-primary" id="subPublic" >提交</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal -->
		</div>
</form>
	<script type="text/javascript">
	    var path = "${ctx}";
	    var tag = "${tag}";
		$(document).ready(function()
		{
			var jqgridH = $(window).height()-345;       
			$("#publicForm").validate({
				debug:true,
				rules: {
					
				},
				messages: {
					
				},
				submitHandler:function(form){
						$('#subPublic').attr('disabled','disabled');  //防止重复提交，请求完毕之前禁用提交按钮
						var url ="${ctx}/mainTenanceProject/save.do";
						publicSubmit(url);
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			$("#jqGrid").jqGrid(
			{ url : '${ctx}/mainTenanceProject/list.do',
			  mtype : "GET",
			  datatype : "json",
			  page : 1,
			  viewrecords: true,
			  colModel:[
				<sec:authorize ifAnyGranted="ROLE_jsbz_xxjc_yhgcfa_editor">
				{ label : "操作", name : "id", 
					  width : 100,   align : 'center', sortable : false, search : false ,
					  classes:'ui-jqgrid-optClass',
					  formatter: function (cellValue, options, rowObject){
							return formatterOpt(cellValue);
					  }
				},
				</sec:authorize>
				{ label : "文件", name : "id", 
					  width : 100,   align : 'center', sortable : false, search : false ,
					  classes:'ui-jqgrid-optClass',
					  formatter: function (cellValue, options, rowObject){
							return "<a href='javascript:void(0);' onclick='openModal(\"T_JS_MAINTENANCEPROJECT\",\"" + cellValue+"\",\"" + rowObject['projectName']+"\");' role='button' >"+
							"<i class='icon-upload' style='margin-top:4px'></i>&nbsp;上传附件</a>";
					  }
				},{
	            	 label: "项目年份",
	            	 name: 'year',
	            	 align: 'center',
	            	 width: 80,
	            	 formatter:function(cellValue,options,rowObject){
		     	        return "<span style='font-weight:bolder'>"+cellValue+"</span>";
		     	     }
	             },{
	            	 label: "项目名称",
	            	 name: 'projectName',
	            	 align: 'center',
	            	 width: 230,
	            	 formatter:function(cellValue,options,rowObject){
			     	        return "<span style='font-weight:bolder'>"+cellValue+"</span>";
			     	     }
	             },{
	               	 label: "项目编号",
	            	 name: 'projectNumber',
	            	 align: 'center',
	            	 width: 150
	             },{
	            	 label: "项目类型",
	         	   	 name: 'projectType',
	         	   	 align: 'center',
	         	   	 width: 200,
	         	    formatter: function (cellValue){
	                 	return Pengtu.buildCodeName(2503,cellValue);
					}
	             },{
	            	 label: "病害诊断分析",
	         	   	 name: 'diagnoses',
	         	   	 align: 'center',
	         	   	 width: 100,
	         	   	 sortable:false,
	         	    formatter: function (cellValue){
	                 	return Pengtu.buildCodeName(2501,cellValue);
					}
	             },{
	            	 label: "项目养护计划",
	         	   	 name: 'maintenancePlan',
	         	   	 align: 'center',
	         	   	 width: 100,
	         	   	sortable:false,
	         	    formatter: function (cellValue){
	                 	return Pengtu.buildCodeName(2502,cellValue);
					}
	             },{
	            	 label: "项目养护效果",
	            	 name: 'maintenanceEffect',
	            	 align: 'center',
	         	   	 width: 100,
	         	   	sortable:false,
	         	   	formatter: function (cellValue){
	                 	return Pengtu.buildCodeName(2500,cellValue);
					}
	             },{
	           	        label: '已上传检查文件',
	           	        name: 'bulletinNumber',
	           	     	align:'center',
	           	        width: 120,
	           	        sortable:false,
	           	        formatter:function(cellValue,options,rowObject){
	           	        	if(cellValue>0){
	           	        		return "<div><img src='${ctx}/images/right.jpg' style='width:20px;height:20px'></div>";
	           	        	}else{
	           	        		return "<img src='${ctx}/images/error.jpg' style='width:20px;height:20px'>";
	           	        	}
	           	        }
	                },{
	            	label: '备注',
	            	name: 'remark',
	            	align:'center',
	            	width: 200,
	            	sortable:false,
	             }
						],
			autowidth : false,width:$(window).width()-248, height : jqgridH,scrollOffset:0, shrinkToFit : 400, rowNum : 10, viewrecords : true, rownumbers : true,
			jsonReader:{
    			root: "result",
    			page: "currentPage",
    			total: "totalPages",
    			records: "totalCount",
    			repeatitems: true,
    			cell: "cell",
    			id: "id",
    			userdata: "userdata",
    			subgrid: {root:"results", repeatitems: true, cell:"cell"}
    		},
    		prmNames: {
				page:"pageNo",
				rows:"pageSize",
				sort: "orderBy",
				order: "order",
				search:"_search",
				nd:"nd", id:"id",
				oper:"oper",
				editoper:"edit",
				addoper:"add",
				deloper:"del",
				subgridid:"id",
				npage: null,
				totalrows:"totalCounts"
			}, 
			rowList :[10,20,30], 
			pager : "#jqGridPager"
			});
		});
		
	function formatterOpt(id) {
		return "<a href='javascript:void(0);' onclick='updatePublic(\"" + id
				+ "\",\"${ctx}/mainTenanceProject/show.do\");' id='" + id
				+ "'  title='修改'><i class='icon icon-edit' style='margin-top:4px;'></i>&nbsp;修改</a>";
	}
</script>
<jsp:include page="/WEB-INF/views/system/attachment.jsp"/> 
</body>
</html>